package com.iretailer.report.web.business;

import com.iretailer.report.base.BaseAction;
import com.iretailer.report.dto.ReHolidays;
import com.iretailer.report.model.Holidays;
import com.iretailer.report.model.User;
import com.iretailer.report.util.RMap;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * @Auther: xjw
 * @Date: 2019/1/25 13:15
 * @Description:
 */
@RestController
public class HolidayController extends BaseAction {


    private Map<String, Object> grid(User user) {
        List<Holidays> holidays = holidayService.selectAllHolidays();
        return RMap.ok(holidays);
    }

    private Map<String, Object> save(ReHolidays reHolidays, User user) {
//        ModelMapper modelMapper = new ModelMapper();
        Holidays holidays = modelMapper.map(reHolidays, Holidays.class);
        boolean result = holidayService.saveOrUpdate(holidays);
        if (result) {
            return RMap.ok();
        } else {
            return RMap.error();
        }
    }

    private Map<String, Object> del(String id) {
        boolean result = holidayService.removeById(id);
        if (result) {
            return RMap.ok();
        } else {
            return RMap.error();
        }
    }


}
